package com.G3.Base;

import com.G3.Global.Assets;
import com.badlogic.gdx.InputAdapter;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Circle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.ui.Image;

public class MyImage extends Image {
	protected TextureAtlas atlas;
	public MyImage( TextureRegion region)
	{
		super(region);
		loadResource();
	}
	
	public void loadResource() {
		atlas = Assets.atlas;
	}

	public MyImage(Vector2 centerPosition, TextureRegion region)
	{
		super(region);
		setPositionFromCenterPosition(centerPosition);
		loadResource();
	}
	
	public void setPositionFromCenterPosition(Vector2 centerPosition)
	{
		this.setPosition(centerPosition.x - this.getWidth()/2, centerPosition.y - this.getHeight()/2);
	}
	
	public Vector2 getCenterPosition()
	{
		return new Vector2(getX() + this.getWidth()/2, this.getY() + this.getHeight()/2);
	}
	
	public Circle getBound()
	{
		return new Circle(getCenterPosition(), this.getWidth() < this.getHeight()? this.getWidth()/2: this.getHeight()/2);
	}
}
